package mo.leetcode_top;

public class L242 {

    public boolean isAnagram(String s, String t) {
        int[] positions = new int[26];
        for (int i = 0; i < s.length(); i++) {
            positions[s.charAt(i)-'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            positions[t.charAt(i)-'a']--;
        }
        for (int i = 0; i < positions.length; i++) {
            if (positions[i] != 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        L242 test = new L242();
        System.out.println(test.isAnagram("anagram", "nagaram"));
    }

}
